package com.easpeed.comon.dialog

import android.content.Context
import android.view.Gravity
import android.view.View
import android.widget.TextView
import androidx.databinding.DataBindingUtil.setContentView
import com.blankj.utilcode.util.ScreenUtils
import com.easpeed.elevator.R

class PopwindowTokePhotoV2(mContext: Context?) : BasePopwindow(mContext) {
    fun showChoose(view: View?, width: Int =-1,  result: (Int) -> Unit): WindowUI {
        val inflate: View = layoutInflater.inflate(R.layout.pop_show_take_photo, null)
        setContentView(inflate)
        ui.cancel = inflate.findViewById<TextView>(R.id.cancel)
        ui.choose = inflate.findViewById<TextView>(R.id.choose)
        ui.takePhoto = inflate.findViewById<TextView>(R.id.take_photo)
        ui.cancel.setOnClickListener { ui.popupWindow.dismiss() }
        ui.choose.setOnClickListener {
            result.invoke(1)
            ui.popupWindow.dismiss()
        }
        ui.takePhoto.setOnClickListener {
            result.invoke(0)
            ui.popupWindow.dismiss()
        }
        val screenWidth = ScreenUtils.getScreenWidth()
        setHeightWidth(-1, width)
        setAnimationStyle()
        setBg(0.5f)
        // 设置好参数之后再show
        ui.popupWindow.showAtLocation(view, Gravity.BOTTOM, 0, 0)
        return ui
    }
}
